<?php 
defined('RUN_KATANA') or die('Restricted access');
if(!($userDetails))
{ $userDetails = new UserDetails($user); }
if(!($forms['customer']))
{ 
	$forms['customer'] = $ac->getForms('profile');
	if($ac->getSetting('alternate-delivery') > 0)
	{ $forms['customer']->Fields['alternate_delivery']->setValue($userDetails->getAlternateDelivery()); }
}
if($ac->getSetting('alternate-delivery') > 0)
{
	if(!($forms['alternate_delivery']))
	{ $forms['alternate_delivery'] = $ac->getForms('alternate_delivery'); }
	else
	{ $forms['alternate_delivery']->validate($txt, $com); }
}
?>
<form id="<?php echo $com->Id; ?>_new_cus" action="<?php echo $katana->getFormAction(); ?>" method="post" enctype="multipart/form-data" name="new_cus">
<div class="row">
	<div class="col-md-6">
		<h3><?php echo ucfirst($txt->getWord('contact').$txt->getWord('information')); ?></h3>
		<fieldset>
			<?php echo $ac->getForms('customer')->getFieldsHTML(); ?>
			<input type="hidden" name="action" value="profile" />
			<input id="<?php echo $com->Id; ?>_new_cus_stealth" type="hidden" name="stealth_<?php echo md5(date("m-d-w")); ?>" value="" />
		</fieldset>
		<?php 
		if(($userDetails->getValid_customer()) && (is_object($shop)))
		{ 
			?>
			<p><a href="/c/16/" class="btn btn-block <?php echo $shop->getSetting('checkout_btn_class'); ?>"><i class="fa fa-credit-card"></i>&nbsp;&nbsp;<?php echo ucfirst($txt->getWord('proceed_to_checkout')); ?>&nbsp;&nbsp;&gt;&gt;</a></p>
			<?php
		}
		?>
	</div>
	<div class="col-md-6">
		<?php if($ac->getSetting('alternate-delivery') > 0): ?>
		<div id="cus_alt_adress" <?php if ($userDetails->getAlternateDelivery() < 1) { echo 'style="display:none;"'; } ?>>
		<h3><?php echo ucfirst($txt->getWord('delivery_address')); ?></h3>
		<fieldset>
			<?php echo $ac->getForms('alternate_delivery')->getFieldsHTML(); ?>
		</fieldset>
		<?php 
		if(($userDetails->getValid_customer()) && (is_object($shop)))
		{ 
			?>
			<p><a href="/c/16/" class="btn btn-block <?php echo $shop->getSetting('checkout_btn_class'); ?>"><i class="fa fa-credit-card"></i>&nbsp;&nbsp;<?php echo ucfirst($txt->getWord('proceed_to_checkout')); ?>&nbsp;&nbsp;&gt;&gt;</a></p>
			<?php
		}
		?>
		</div>
		<script type="text/javascript">
		function checkAlternateDelivery(selected)
		{
			if(selected == 1)
			{
				$('#cus_alt_adress').css('display', 'block');
				$('#cus_alt_adress input.required').each(function() 
				{ 
					$(this).attr("required", "required"); 
					$(this).removeClass("required"); 
				});
				$('#cus_alt_adress').focus();
			}
			else
			{
				$('#cus_alt_adress').css('display', 'none');
				$('#cus_alt_adress input:required').each(function() 
				{ $( this ).addClass( "required" ); });
				$('#cus_alt_adress input').removeAttr('required');
			}
		}
		
		$(document).ready(function() 
		{ 
			checkAlternateDelivery(<?php echo $userDetails->getAlternateDelivery(); ?>);
			$("select#alternate_delivery").change(function () 
			{ checkAlternateDelivery($(this).val()); });
		})
		</script>
		<?php endif; ?>
	</div>
</div>
</form>
<?php $katana->addAnalyticsTrack("_gaq.push(['_trackPageview', '/user/customer']);"); ?>